<?php

namespace app\admin\model;

//加载配置类
use think\Config;
//导入Controller
use think\Model;
//导入Db
use think\Db;
//引入Session类
use think\Session;

class IndexModel extends Model
{
	/**
	*	获取登录管理员的信息
	*/
	public function getAdminUser($admin_id)
	{
		$result = Db::table('sz_adminuser')->where('id',$admin_id)->find();
		return $result;
	}

	/**
	*	修改密码提交
	*/
	public function editpassPost($admin_id,$data)
	{
		$result = Db::table('sz_adminuser')->where('id',$admin_id)->find();
		if(md5($data['oldpass']) === $result['password']){
			
			if($data['newpass'] === $data['confpass']){
				$newpass = md5($data['newpass']);
				$res = Db::table('sz_adminuser')->where('id',$admin_id)->update(['password'=>$newpass]);
				return $res;

			}else{
				//新密码和确认密码不一致
				return 3;
			}
			
		}else{
			// 原密码不正确
			return 2;
		}
	}

	
}